# --*coding:utf-8*--

def test(nums):

    list_len = len(nums)
    for k in range(len(nums)):
        # if k < list_len:
            for i in range(k + 1, len(nums)):
                if i  < list_len:
                    if nums[k] == nums[i]:
                        del (nums[i])

                else:
                    exit()

    else:
        print('stop')
        exit()
    print nums
    pass

def ShellSort(lst,d):
    def shellinsert(arr, d):
        n = len(arr)
        for i in range(d, n):
            j = i - d
            temp = arr[i]       #记录要出入的数
            while (j >= 0 and arr[j] > temp):  #从后向前，找打比其小的数的位置
                arr[j + d] = arr[j]    # 向后挪动
                j -= d
            if j != i - d:
                arr[j + d] = temp

    n = len(lst)
    if n <= 1:
        return lst
    d = n // 2
    while d >= 1:
        shellinsert(lst, d)
        d = d // 2
    return lst

import random




def tests(A):
    strnum = ''
    for eachNum in A:
        strnum += str(eachNum)
    print 'str:',strnum
    intnum = int(strnum) + 222
    print intnum
    bb = str(intnum)
    list = []
    for i in bb:
        list.append(int(i))
    print list


def outter(func):

    def inner(*args, **kwargs):
        print('装饰a....')
        re=func(*args, **kwargs)
        print('re:',re)
        return re

    # print('inner:',inner)
    # print('func:',func)
    return inner
@outter
def a(num):
    print("被装饰了。。。")




class lazy(object):
    def __init__(self, func):
        self.func = func

    def __get__(self, instance, cls):
        val = self.func(instance)  # 其相当于执行的area(c),c为下面的Circle对象
        print('val:',val)
        print('instance:',instance,'cls:',cls)

        setattr(instance, self.func.__name__, val)
        return val


class Circle(object):
    def __init__(self, radius):
        self.radius = radius

    @lazy
    def area(self):
        print('evalute')
        return 3+self.radius

    @lazy
    def RandomPhone(se):
        prelist = ["130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "147", "150", "151", "152",
                   "153", "155", "156", "157", "158", "159", "186", "187", "188"]
        randomPre = random.choice(prelist)

        Number = "".join(random.choice("0123456789") for i in range(8))
        phoneNum = randomPre + Number
        return phoneNum

if __name__ == '__main__':

    # c = Circle(5)
    # print(c.area)
    # print('dict:',c.__dict__)
    # print(c.area)
    # print(c.area)
    for i in range(100):
        print('phone:',Circle(1).RandomPhone)
        print('dict:',Circle(1).__dict__)

# if __name__ == '__main__':
#     # nums = [1, 1, 1,1, 0, 0, 0]
#     # # test(nums)
#     # # tests(nums)
#     #
#     # aa = ShellSort([0, 5, 2, 10, 8, 2],3)
#     a(2)